from django.db import models
from django.contrib.auth.models import User

class TaskList(models.Model):
    def __unicode__(self):
        return self.name
        
    name = models.CharField(max_length=128)
    note = models.TextField("Note")
    user = models.ForeignKey(User)

class Task(models.Model):
    def __unicode__(self):
        return self.name

    name = models.CharField("Name", max_length=128)
    list = models.ForeignKey(TaskList, null=True, blank=True)
    note = models.TextField("Note")
    user = models.ForeignKey(User)
    created = models.DateTimeField('Creation date', auto_now_add=True)
    modified = models.DateTimeField('Modification time', auto_now=True)
    
    TODO = 0
    IN_PROGRESS=1
    FINISHED=2
    STATE_CHOICES = (
    (TODO, "To do"),
    (IN_PROGRESS, "In progress"),
    (FINISHED, "Finished")
    )
    state = models.SmallIntegerField("State", choices=STATE_CHOICES, default=TODO)
    
class Report(models.Model):
    GOOD=0
    GOOD_NAME = "Good"
    BAD=1
    BAD_NAME = "Bad"
    MORE=2
    MORE_NAME = "More/start doing"
    LESS=3
    LESS_NAME = "Less/stop doing"
    LIST_CHOICES = (
        (GOOD, GOOD_NAME),
        (BAD, BAD_NAME),
        (MORE, MORE_NAME),
        (LESS, LESS_NAME),
    )
    list = models.SmallIntegerField("List", choices=LIST_CHOICES)
    note = models.TextField("Note")
    order = models.IntegerField("Order")
    period = models.ForeignKey(TaskList, unique=True)
    
class LeftWork(models.Model):
    hours = models.FloatField("Left hours")
    when = models.DateTimeField("When")
    period = models.ForeignKey(TaskList)

    
    
    
    
    
